home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / Interfaces&Libraries / Universal / Interfaces / CIncludes / QD3DDrawContext.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-17  |  14.6 KB  |  514 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        QD3DDrawContext.h
  3.  
  4.      Contains:    Draw context class types and routines                               
  5.  
  6.      Version:    Technology:    Quickdraw 3D 1.5.4
  7.                  Release:    Universal Interfaces 3.2
  8.  
  9.      Copyright:    © 1995-1998 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __QD3DDRAWCONTEXT__
  18. #define __QD3DDRAWCONTEXT__
  19.  
  20. #ifndef __QD3D__
  21. #include <QD3D.h>
  22. #endif
  23.  
  24. #if TARGET_OS_MAC
  25. #ifndef __QUICKDRAW__
  26. #include <Quickdraw.h>
  27. #endif
  28. #ifndef __FIXMATH__
  29. #include <FixMath.h>
  30. #endif
  31. #ifndef __GXTYPES__
  32. #include <GXTypes.h>
  33. #endif
  34. #endif  /* TARGET_OS_MAC */
  35.  
  36.  
  37. #if TARGET_OS_UNIX
  38.     #include <X11/Xlib.h>
  39.     #include <X11/Xutil.h>
  40. #endif    /* TARGET_OS_WIN32 */
  41.  
  42.  
  43. #if TARGET_OS_WIN32
  44.     /******************************************************************************
  45.      *                                                                             **
  46.      * ABOUT   QD3D_NO_DIRECTDRAW:     (Win32 Only)                                 **
  47.      *                                                                             **
  48.      * NOTE: Define QD3D_NO_DIRECTDRAW for your application makefile/project     **
  49.      *       only if you don't need Q3DDSurfaceDrawContext support and don't     **
  50.      *       have access to ddraw.h.                                             ** 
  51.      *                                                                             **
  52.      *****************************************************************************/
  53.     #include <windows.h>
  54.     #if !defined(QD3D_NO_DIRECTDRAW)
  55.         #include <ddraw.h>
  56.     #endif /* !QD3D_NO_DIRECTDRAW */
  57. #endif  /*  TARGET_OS_WIN32  */
  58.  
  59.  
  60.  
  61. #if PRAGMA_ONCE
  62. #pragma once
  63. #endif
  64.  
  65. #ifdef __cplusplus
  66. extern "C" {
  67. #endif
  68.  
  69. #if PRAGMA_IMPORT
  70. #pragma import on
  71. #endif
  72.  
  73. #if PRAGMA_STRUCT_ALIGN
  74.     #pragma options align=power
  75. #elif PRAGMA_STRUCT_PACKPUSH
  76.     #pragma pack(push, 2)
  77. #elif PRAGMA_STRUCT_PACK
  78.     #pragma pack(2)
  79. #endif
  80.  
  81. #if PRAGMA_ENUM_ALWAYSINT
  82.     #pragma enumsalwaysint on
  83. #elif PRAGMA_ENUM_OPTIONS
  84.     #pragma option enum=int
  85. #elif PRAGMA_ENUM_PACK
  86.     #if __option(pack_enums)
  87.         #define PRAGMA_ENUM_PACK__QD3DDRAWCONTEXT__
  88.     #endif
  89.     #pragma options(!pack_enums)
  90. #endif
  91.  
  92. /******************************************************************************
  93.  **                                                                             **
  94.  **                            DrawContext Data Structures                         **
  95.  **                                                                             **
  96.  *****************************************************************************/
  97.  
  98. enum TQ3DrawContextClearImageMethod {
  99.     kQ3ClearMethodNone            = 0,
  100.     kQ3ClearMethodWithColor        = 1
  101. };
  102. typedef enum TQ3DrawContextClearImageMethod TQ3DrawContextClearImageMethod;
  103.  
  104.  
  105.  
  106. struct TQ3DrawContextData {
  107.     TQ3DrawContextClearImageMethod     clearImageMethod;
  108.     TQ3ColorARGB                     clearImageColor;
  109.     TQ3Area                         pane;
  110.     TQ3Boolean                         paneState;
  111.     TQ3Bitmap                         mask;
  112.     TQ3Boolean                         maskState;
  113.     TQ3Boolean                         doubleBufferState;
  114. };
  115. typedef struct TQ3DrawContextData        TQ3DrawContextData;
  116. /******************************************************************************
  117.  **                                                                             **
  118.  **                                DrawContext Routines                         **
  119.  **                                                                             **
  120.  *****************************************************************************/
  121. EXTERN_API_C( TQ3ObjectType )
  122. Q3DrawContext_GetType            (TQ3DrawContextObject     drawContext);
  123.  
  124. EXTERN_API_C( TQ3Status )
  125. Q3DrawContext_SetData            (TQ3DrawContextObject     context,
  126.                                  const TQ3DrawContextData * contextData);
  127.  
  128. EXTERN_API_C( TQ3Status )
  129. Q3DrawContext_GetData            (TQ3DrawContextObject     context,
  130.                                  TQ3DrawContextData *    contextData);
  131.  
  132. EXTERN_API_C( TQ3Status )
  133. Q3DrawContext_SetClearImageColor (TQ3DrawContextObject     context,
  134.                                  const TQ3ColorARGB *    color);
  135.  
  136. EXTERN_API_C( TQ3Status )
  137. Q3DrawContext_GetClearImageColor (TQ3DrawContextObject     context,
  138.                                  TQ3ColorARGB *            color);
  139.  
  140. EXTERN_API_C( TQ3Status )
  141. Q3DrawContext_SetPane            (TQ3DrawContextObject     context,
  142.                                  const TQ3Area *        pane);
  143.  
  144. EXTERN_API_C( TQ3Status )
  145. Q3DrawContext_GetPane            (TQ3DrawContextObject     context,
  146.                                  TQ3Area *                pane);
  147.  
  148. EXTERN_API_C( TQ3Status )
  149. Q3DrawContext_SetPaneState        (TQ3DrawContextObject     context,
  150.                                  TQ3Boolean             state);
  151.  
  152. EXTERN_API_C( TQ3Status )
  153. Q3DrawContext_GetPaneState        (TQ3DrawContextObject     context,
  154.                                  TQ3Boolean *            state);
  155.  
  156. EXTERN_API_C( TQ3Status )
  157. Q3DrawContext_SetClearImageMethod (TQ3DrawContextObject  context,
  158.                                  TQ3DrawContextClearImageMethod  method);
  159.  
  160. EXTERN_API_C( TQ3Status )
  161. Q3DrawContext_GetClearImageMethod (TQ3DrawContextObject  context,
  162.                                  TQ3DrawContextClearImageMethod * method);
  163.  
  164. EXTERN_API_C( TQ3Status )
  165. Q3DrawContext_SetMask            (TQ3DrawContextObject     context,
  166.                                  const TQ3Bitmap *        mask);
  167.  
  168. EXTERN_API_C( TQ3Status )
  169. Q3DrawContext_GetMask            (TQ3DrawContextObject     context,
  170.                                  TQ3Bitmap *            mask);
  171.  
  172. EXTERN_API_C( TQ3Status )
  173. Q3DrawContext_SetMaskState        (TQ3DrawContextObject     context,
  174.                                  TQ3Boolean             state);
  175.  
  176. EXTERN_API_C( TQ3Status )
  177. Q3DrawContext_GetMaskState        (TQ3DrawContextObject     context,
  178.                                  TQ3Boolean *            state);
  179.  
  180. EXTERN_API_C( TQ3Status )
  181. Q3DrawContext_SetDoubleBufferState (TQ3DrawContextObject  context,
  182.                                  TQ3Boolean             state);
  183.  
  184. EXTERN_API_C( TQ3Status )
  185. Q3DrawContext_GetDoubleBufferState (TQ3DrawContextObject  context,
  186.                                  TQ3Boolean *            state);
  187.  
  188.  
  189. /******************************************************************************
  190.  **                                                                             **
  191.  **                            Pixmap Data Structure                             **
  192.  **                                                                             **
  193.  *****************************************************************************/
  194.  
  195. struct TQ3PixmapDrawContextData {
  196.     TQ3DrawContextData                 drawContextData;
  197.     TQ3Pixmap                         pixmap;
  198. };
  199. typedef struct TQ3PixmapDrawContextData    TQ3PixmapDrawContextData;
  200. /******************************************************************************
  201.  **                                                                             **
  202.  **                        Pixmap DrawContext Routines                             **
  203.  **                                                                             **
  204.  *****************************************************************************/
  205. EXTERN_API_C( TQ3DrawContextObject )
  206. Q3PixmapDrawContext_New            (const TQ3PixmapDrawContextData * contextData);
  207.  
  208. EXTERN_API_C( TQ3Status )
  209. Q3PixmapDrawContext_SetPixmap    (TQ3DrawContextObject     drawContext,
  210.                                  const TQ3Pixmap *        pixmap);
  211.  
  212. EXTERN_API_C( TQ3Status )
  213. Q3PixmapDrawContext_GetPixmap    (TQ3DrawContextObject     drawContext,
  214.                                  TQ3Pixmap *            pixmap);
  215.  
  216.  
  217.  
  218. #if TARGET_OS_MAC
  219. /******************************************************************************
  220.  **                                                                             **
  221.  **                        Macintosh DrawContext Data Structures                 **
  222.  **                                                                             **
  223.  *****************************************************************************/
  224.  
  225. enum TQ3MacDrawContext2DLibrary {
  226.     kQ3Mac2DLibraryNone            = 0,
  227.     kQ3Mac2DLibraryQuickDraw    = 1,
  228.     kQ3Mac2DLibraryQuickDrawGX    = 2
  229. };
  230. typedef enum TQ3MacDrawContext2DLibrary TQ3MacDrawContext2DLibrary;
  231.  
  232.  
  233.  
  234. struct TQ3MacDrawContextData {
  235.     TQ3DrawContextData                 drawContextData;
  236.     CWindowPtr                         window;
  237.     TQ3MacDrawContext2DLibrary         library;
  238.     gxViewPort                         viewPort;
  239.     CGrafPtr                         grafPort;
  240. };
  241. typedef struct TQ3MacDrawContextData    TQ3MacDrawContextData;
  242. /******************************************************************************
  243.  **                                                                             **
  244.  **                        Macintosh DrawContext Routines                         **
  245.  **                                                                             **
  246.  *****************************************************************************/
  247. EXTERN_API_C( TQ3DrawContextObject )
  248. Q3MacDrawContext_New            (const TQ3MacDrawContextData * drawContextData);
  249.  
  250. EXTERN_API_C( TQ3Status )
  251. Q3MacDrawContext_SetWindow        (TQ3DrawContextObject     drawContext,
  252.                                  CWindowPtr             window);
  253.  
  254. EXTERN_API_C( TQ3Status )
  255. Q3MacDrawContext_GetWindow        (TQ3DrawContextObject     drawContext,
  256.                                  CWindowPtr *            window);
  257.  
  258. EXTERN_API_C( TQ3Status )
  259. Q3MacDrawContext_SetGXViewPort    (TQ3DrawContextObject     drawContext,
  260.                                  gxViewPort             viewPort);
  261.  
  262. EXTERN_API_C( TQ3Status )
  263. Q3MacDrawContext_GetGXViewPort    (TQ3DrawContextObject     drawContext,
  264.                                  gxViewPort *            viewPort);
  265.  
  266. EXTERN_API_C( TQ3Status )
  267. Q3MacDrawContext_SetGrafPort    (TQ3DrawContextObject     drawContext,
  268.                                  CGrafPtr                 grafPort);
  269.  
  270. EXTERN_API_C( TQ3Status )
  271. Q3MacDrawContext_GetGrafPort    (TQ3DrawContextObject     drawContext,
  272.                                  CGrafPtr *                grafPort);
  273.  
  274. EXTERN_API_C( TQ3Status )
  275. Q3MacDrawContext_Set2DLibrary    (TQ3DrawContextObject     drawContext,
  276.                                  TQ3MacDrawContext2DLibrary  library);
  277.  
  278. EXTERN_API_C( TQ3Status )
  279. Q3MacDrawContext_Get2DLibrary    (TQ3DrawContextObject     drawContext,
  280.                                  TQ3MacDrawContext2DLibrary * library);
  281.  
  282. #endif  /* TARGET_OS_MAC */
  283.  
  284. #if TARGET_OS_UNIX
  285. /******************************************************************************
  286.  **                                                                             **
  287.  **                        X/Windows DrawContext Data Structures                 **
  288.  **                                                                             **
  289.  *****************************************************************************/
  290. typedef struct OpaqueTQ3XBufferObject*     TQ3XBufferObject;
  291.  
  292. struct TQ3XColormapData {
  293.     long                             baseEntry;
  294.     long                             maxRed;
  295.     long                             maxGreen;
  296.     long                             maxBlue;
  297.     long                             multRed;
  298.     long                             multGreen;
  299.     long                             multBlue;
  300. };
  301. typedef struct TQ3XColormapData            TQ3XColormapData;
  302.  
  303. struct TQ3XDrawContextData {
  304.     TQ3DrawContextData                 contextData;
  305.     Display *                        display;
  306.     Drawable                         drawable;
  307.     Visual *                        visual;
  308.     Colormap                         cmap;
  309.     TQ3XColormapData *                colorMapData;
  310. };
  311. typedef struct TQ3XDrawContextData        TQ3XDrawContextData;
  312. /******************************************************************************
  313.  **                                                                             **
  314.  **                        X/Windows DrawContext Routines                         **
  315.  **                                                                             **
  316.  *****************************************************************************/
  317. #ifdef XDC_OLD
  318. EXTERN_API_C( TQ3DrawContextObject )
  319. Q3XDrawContext_New                (void);
  320.  
  321. EXTERN_API_C( void )
  322. Q3XDrawContext_Set                (TQ3DrawContextObject     drawContext,
  323.                                  unsigned long             flag,
  324.                                  void *                    data);
  325.  
  326. EXTERN_API_C( void )
  327. Q3XDrawContext_Get                (TQ3DrawContextObject     drawContext,
  328.                                  unsigned long             flag,
  329.                                  void *                    data);
  330.  
  331. #endif  /* defined(XDC_OLD) */
  332.  
  333. EXTERN_API_C( TQ3XBufferObject )
  334. Q3XBuffers_New                    (Display *                dpy,
  335.                                  unsigned long             numBuffers,
  336.                                  Window                 window);
  337.  
  338. EXTERN_API_C( void )
  339. Q3XBuffers_Swap                    (Display *                dpy,
  340.                                  TQ3XBufferObject         buffers);
  341.  
  342. EXTERN_API_C( XVisualInfo *)
  343. Q3X_GetVisualInfo                (Display *                dpy,
  344.                                  Screen *                screen);
  345.  
  346.  
  347. EXTERN_API_C( TQ3DrawContextObject )
  348. Q3XDrawContext_New                (const TQ3XDrawContextData * xContextData);
  349.  
  350. EXTERN_API_C( TQ3Status )
  351. Q3XDrawContext_SetDisplay        (TQ3DrawContextObject     drawContext,
  352.                                  const Display *        display);
  353.  
  354. EXTERN_API_C( TQ3Status )
  355. Q3XDrawContext_GetDisplay        (TQ3DrawContextObject     drawContext,
  356.                                  Display **                display);
  357.  
  358. EXTERN_API_C( TQ3Status )
  359. Q3XDrawContext_SetDrawable        (TQ3DrawContextObject     drawContext,
  360.                                  Drawable                 drawable);
  361.  
  362. EXTERN_API_C( TQ3Status )
  363. Q3XDrawContext_GetDrawable        (TQ3DrawContextObject     drawContext,
  364.                                  Drawable *                drawable);
  365.  
  366. EXTERN_API_C( TQ3Status )
  367. Q3XDrawContext_SetVisual        (TQ3DrawContextObject     drawContext,
  368.                                  const Visual *            visual);
  369.  
  370. EXTERN_API_C( TQ3Status )
  371. Q3XDrawContext_GetVisual        (TQ3DrawContextObject     drawContext,
  372.                                  Visual **                visual);
  373.  
  374. EXTERN_API_C( TQ3Status )
  375. Q3XDrawContext_SetColormap        (TQ3DrawContextObject     drawContext,
  376.                                  Colormap                 colormap);
  377.  
  378. EXTERN_API_C( TQ3Status )
  379. Q3XDrawContext_GetColormap        (TQ3DrawContextObject     drawContext,
  380.                                  Colormap *                colormap);
  381.  
  382. EXTERN_API_C( TQ3Status )
  383. Q3XDrawContext_SetColormapData    (TQ3DrawContextObject     drawContext,
  384.                                  const TQ3XColormapData * colormapData);
  385.  
  386. EXTERN_API_C( TQ3Status )
  387. Q3XDrawContext_GetColormapData    (TQ3DrawContextObject     drawContext,
  388.                                  TQ3XColormapData *        colormapData);
  389.  
  390. #endif  /* TARGET_OS_UNIX */
  391.  
  392. #if TARGET_OS_WIN32
  393. /******************************************************************************
  394.  **                                                                             **
  395.  **                         Win32 DrawContext Data Structures                      **
  396.  **                                                                             **
  397.  *****************************************************************************/
  398.  
  399. struct TQ3Win32DCDrawContextData {
  400.     TQ3DrawContextData                 drawContextData;
  401.     HDC                             hdc;
  402. };
  403. typedef struct TQ3Win32DCDrawContextData TQ3Win32DCDrawContextData;
  404. #ifndef QD3D_NO_DIRECTDRAW
  405.  
  406. enum TQ3DirectDrawObjectSelector {
  407.     kQ3DirectDrawObject            = 1,
  408.     kQ3DirectDrawObject2        = 2
  409. };
  410. typedef enum TQ3DirectDrawObjectSelector TQ3DirectDrawObjectSelector;
  411.  
  412.  
  413. enum TQ3DirectDrawSurfaceSelector {
  414.     kQ3DirectDrawSurface        = 1,
  415.     kQ3DirectDrawSurface2        = 2
  416. };
  417. typedef enum TQ3DirectDrawSurfaceSelector TQ3DirectDrawSurfaceSelector;
  418.  
  419.  
  420. struct TQ3DDSurfaceDescriptor {
  421.     TQ3DirectDrawObjectSelector        objectSelector;
  422.     union
  423.     {
  424.         LPDIRECTDRAW                lpDirectDraw;
  425.         LPDIRECTDRAW2                lpDirectDraw2;
  426.     };
  427.  
  428.     TQ3DirectDrawSurfaceSelector    surfaceSelector;
  429.     union
  430.     {
  431.         LPDIRECTDRAWSURFACE            lpDirectDrawSurface;
  432.         LPDIRECTDRAWSURFACE2        lpDirectDrawSurface2;
  433.     };
  434. };
  435. typedef struct TQ3DDSurfaceDescriptor TQ3DDSurfaceDescriptor;
  436.  
  437. struct TQ3DDSurfaceDrawContextData {
  438.     TQ3DrawContextData                drawContextData;
  439.     TQ3DDSurfaceDescriptor            ddSurfaceDescriptor;
  440. };
  441. typedef struct TQ3DDSurfaceDrawContextData TQ3DDSurfaceDrawContextData;
  442.  
  443. #endif  /* !defined(QD3D_NO_DIRECTDRAW) */
  444.  
  445. /******************************************************************************
  446.  **                                                                             **
  447.  **                            Win32DC DrawContext Routines                     **
  448.  **                                                                             **
  449.  *****************************************************************************/
  450. EXTERN_API_C( TQ3DrawContextObject )
  451. Q3Win32DCDrawContext_New        (const TQ3Win32DCDrawContextData * drawContextData);
  452.  
  453. EXTERN_API_C( TQ3Status )
  454. Q3Win32DCDrawContext_SetDC        (TQ3DrawContextObject     drawContext,
  455.                                  HDC                     newHDC);
  456.  
  457. EXTERN_API_C( TQ3Status )
  458. Q3Win32DCDrawContext_GetDC        (TQ3DrawContextObject     drawContext,
  459.                                  HDC *                    curHDC);
  460.  
  461. /******************************************************************************
  462.  **                                                                             **
  463.  **                            DDSurface DrawContext Routines                     **
  464.  **                                                                             **
  465.  *****************************************************************************/
  466. #ifndef QD3D_NO_DIRECTDRAW
  467. EXTERN_API_C( TQ3DrawContextObject )
  468. Q3DDSurfaceDrawContext_New        (const TQ3DDSurfaceDrawContextData * drawContextData);
  469.  
  470. EXTERN_API_C( TQ3Status )
  471. Q3DDSurfaceDrawContext_SetDirectDrawSurface (TQ3DrawContextObject  drawContext,
  472.                                  const TQ3DDSurfaceDescriptor * ddSurfaceDescriptor);
  473.  
  474. EXTERN_API_C( TQ3Status )
  475. Q3DDSurfaceDrawContext_GetDirectDrawSurface (TQ3DrawContextObject  drawContext,
  476.                                  TQ3DDSurfaceDescriptor * ddSurfaceDescriptor);
  477.  
  478. #endif  /* !defined(QD3D_NO_DIRECTDRAW) */
  479.  
  480. #endif  /* TARGET_OS_WIN32 */
  481.  
  482.  
  483.  
  484.  
  485.  
  486. #if PRAGMA_ENUM_ALWAYSINT
  487.     #pragma enumsalwaysint reset
  488. #elif PRAGMA_ENUM_OPTIONS
  489.     #pragma option enum=reset
  490. #elif defined(PRAGMA_ENUM_PACK__QD3DDRAWCONTEXT__)
  491.     #pragma options(pack_enums)
  492. #endif
  493.  
  494. #if PRAGMA_STRUCT_ALIGN
  495.     #pragma options align=reset
  496. #elif PRAGMA_STRUCT_PACKPUSH
  497.     #pragma pack(pop)
  498. #elif PRAGMA_STRUCT_PACK
  499.     #pragma pack()
  500. #endif
  501.  
  502. #ifdef PRAGMA_IMPORT_OFF
  503. #pragma import off
  504. #elif PRAGMA_IMPORT
  505. #pragma import reset
  506. #endif
  507.  
  508. #ifdef __cplusplus
  509. }
  510. #endif
  511.  
  512. #endif /* __QD3DDRAWCONTEXT__ */
  513.  
  514.